package com.gryffonx.Interfaces.generators;

import com.gryffonx.utils.StringUtils;
import com.main.UIOptions.NameGeneratorMenuBar;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @author Erik Stell
 * @version 1.0
 */
public class NameGenerators extends JFrame {
    private final NameGeneratorsBinding thisPanel = new NameGeneratorsBinding();

    /**
     * @param title
     * @throws HeadlessException
     */
    public NameGenerators(String title) throws HeadlessException {
        super(title);
        ImageIcon appIcon = StringUtils.createImageIcon("/images/appIcon2.gif");
        this.setIconImage(appIcon.getImage());
        //set the menu bar
        this.setJMenuBar(NameGeneratorMenuBar.getMenu(thisPanel));
        //populate the content pane
        this.setContentPane(thisPanel.getPnlMainPanel());

        this.setResizable(false);

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });        

    }

    public static void main(String[] args) {
        //set look and feel
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }        
        NameGenerators window = new NameGenerators("Name Generators");
        window.pack();
        window.setLocation(((Toolkit.getDefaultToolkit().getScreenSize().width / 2) -
                (window.getWidth() / 2)),
                ((Toolkit.getDefaultToolkit().getScreenSize().height / 2) -
                        (window.getHeight() / 2)));
        window.setVisible(true);
    }
}
